Describe the different type of roles in SQL Server.
Describe the different type of roles in SQL Server.
23315-Jul-2024
Updated on 16-Jul-2024
Home / DeveloperSection / Forums / Describe the different type of roles in SQL Server.
Describe the different type of roles in SQL Server.
Ashutosh Kumar Verma
16-Jul-2024SQL Server Roles
A role is a set of permissions. Functions help simplify route planning. For example, instead of assigning permissions to individual users, you can group permissions into roles and add users to those roles.
SQL Server Role Type
SQL Server provides you with three main role types,
Server-level Roles – manage the permissions on SQL Server, like changing server configuration.
Database Level Roles – Manage permissions on databases such as creating tables and querying data.
Application level Role– Allow applications to run with their own, user-like permissions.
SQL Server provides two types for each role,
Fixed server roles are created roles provided by SQL Server. These functions have fixed licenses.
User-defined roles creates a role that you define to meet a specific security need.
Adding a user to a Role
First, create a new login called
testLogin
Now, switch the current database to
MyCollegeDb
and create a user fortestLogin
loginThen, connect to the
MyCollegeDb
database using userMyUser
. UserMyUser
can view theMyCollegeDb
database but cannot see any database objects.After that, add the user
MyUser
to thedb_datareader
role.db_datareader
is a fixed database role. Thedb_datareader
role allows all members to read data from all user tables and views in the database. Technically, it is equivalent to the followingGRANT
statementIn this example,
DATABASE
is a class type that comes after::
indicating a separable that is a database. Following are the available class types,Finally, switch the connection to the user
MyUser
and select data from thedbo.Employees
table,Also, Read: How to create user-defined role in SQL Server Database?